﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace GabageFactory.Models
{
    public class GraphReposity : Reposity
    {
        public IEnumerable<Factory_daily_weather_info> GetRainfall(int factoryId, DateTime fromDate, DateTime toDate)
        {
            var weathers = from s in _dataContext.Factory_daily_weather_infos
                             where factoryId == s.factory_id && s.date >= fromDate.Date && s.date <= toDate.Date
                             select s;

            return weathers;
        }

        public Factory_daily_weather_info CreateDailyWeather(Factory_daily_weather_info dailyWeather)
        {
            _dataContext.Factory_daily_weather_infos.InsertOnSubmit(dailyWeather);
            SubmitChanges();
            return dailyWeather;
        }

        public bool DeleteDailyWeather(Factory_daily_weather_info dailyWeather)
        {
            _dataContext.Factory_daily_weather_infos.DeleteOnSubmit(dailyWeather);
            return true;
        }
    }
}